<template>
  <div class="app-container"
  style="text-align: center;height: calc(100vh - 45px);overflow: scroll;">
    <a-spin :spinning="fullscreenLoading">
      <iframe ref="iframe" :src="urlPath" class="iframe" />
    </a-spin>
  </div>
</template>

<script>
export default {
  name: 'CreditReportInterpretation',
  components: {},
  props: {
    reportNo: {
      type: String,
      default() {
        return ''
      }
    }
  },
  data() {
    return {
      fullscreenLoading: false,
      urlPath: 'http://localhost:9777/viewReport.html'
    }
  },
  watch: {
    routerPath: function(val) {
      this.urlPath = 'http://localhost:9777/viewReport.html'
    }
  },
  created() {
    this.urlPath = 'http://localhost:9777/repair/c?reportNo=' + this.reportNo
    this.fullscreenLoading = true
  },
  mounted() {
    this.iframeInit()
    window.onresize = () => {
      this.iframeInit()
    }
  },
  methods: {
    iframeInit() {
      const iframe = this.$refs.iframe
      const clientHeight = document.documentElement.clientHeight - 45
      iframe.style.height = `${clientHeight}px`
      if (iframe.attachEvent) {
        iframe.attachEvent('onload', () => {
          this.fullscreenLoading = false
        })
      } else {
        iframe.onload = () => {
          this.fullscreenLoading = false
        }
      }
    },
    getUrlPath: function() {
      let url = window.location.href
      url = url.replace('/iframe', '')
      return url
    }
  }
}
</script>

<style scoped>
  .iframe {
    width: 100%;
     /*height: calc(100vh - 50px - 65px - 20px - 20px) !important; */
    border: 0;
    overflow: hidden;
    box-sizing: border-box;
  }
</style>
